<%#
    Auth: Wen
    Version: V1.0
    Data: 2019.8.20
    Function:
%>
<%+header%>
	<!DOCTYPE html>
	<html>
	<head>
		<meta charset="utf-8">
		<title>第一个 ECharts 实例</title>
	</head>
	<body>
		<div>
			<div id="event_time" style="display:inline-block;width:400px; height:400px;" value="1">
				<table class="table table-striped">
			
					<thead>
						<tr>
							<th id= "page"><%:Page %>0</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td id = "event0"></td>
						</tr>
						<tr>
							<td id = "event1"></td>
						</tr>
						<tr>
							<td id = "event2"></td>
						</tr>
						<tr>
							<td id = "event3"></td>
						</tr>
						<tr>
							<td id = "event4"></td>
						</tr>
						<tr>
							<td id = "event5"></td>
						</tr>
						<tr>
							<td id = "event6"></td>
						</tr>
						<tr>
							<td id = "event7"></td>
						</tr>
						<tr>
							<td id = "event8"></td>
						</tr>
						<tr>
							<td id = "event9"></td>
						</tr>
						<tr>
							<td id = "event10"></td>
						</tr>
						<tr>
							<td id = "event11"></td>
						</tr>
						<tr>
							<td id = "event12"></td>
						</tr>	
						<tr>
							<td id = "event13"></td>
						</tr>
						<tr>
							<td id = "event14"></td>
						</tr>
						<tr>
							<td id = "event15"></td>
						</tr>
						<tr>
							<td id = "event16"></td>
						</tr>
						<tr>
							<td id = "event17"></td>
						</tr>
						<tr>
							<td id = "event18"></td>
						</tr>
						<tr>
							<td id = "event19"></td>
						</tr>
						<tr>
							<td id = "event20"></td>
						</tr>
						<tr>
							<td id = "event21"></td>
						</tr>
						<tr>
							<td id = "event22"></td>
						</tr>
						<tr>
							<td id = "event23"></td>
						</tr>
						<tr>
							<td id = "event24"></td>
						</tr>
						<tr>
							<td id = "event25"></td>
						</tr>
						<tr>
							<td id = "event26"></td>
						</tr>
						<tr>
							<td id = "event27"></td>
						</tr>
						<tr>
							<td id = "event28"></td>
						</tr>
						<tr>
							<td id = "event29"></td>
						</tr>
					</tbody>
				</table>
				<ul class="pager">
				<li><a href="#" onclick="pageDesc()"><%:Previous Page%></a></li>
				<li><a href="#" onclick="pageInc()"><%:Next Page%></a></li>
				<li><a href="#" onclick="clearLog()"><%:Clean Log%></a></li>
				</ul>					
			</div>
		</div>
		<script type="text/javascript">
			var log_xhr = new XHR();

			//获取SNR值与时间的关系
			var page_num = 0;
			var page_size = 30;
			var MAX_PAGE = 34;

			//获取告警日志内容
			function getLog(pgn, pgs)
			{
				log_xhr.post('<%=controller%>admin/ACU_Antenna/getLog', {token:'<%=token%>', pgn, pgs}, function(x){
					
					console.log(x.responseText);
					//对返回的数据进行解析，并填入到相应的控件				
					var log_1 = x.responseText.split(";");
				
					var log_2 = [];
					var event = "";
					for(var i = 0; i < page_size ; i++)
					{
						if((log_1[i] != undefined) && (log_1[i] != ""))
						{
							event = "event" + i;
							log_2 = log_1[i].split(",");
							if(log_2[1] == 3)
							{
								document.getElementById(event).style.color="red";
							}
							else if(log_2[1] == 2)
							{
								document.getElementById(event).style.color="green";
							}
							else
							{
								document.getElementById(event).style.color="#666";
							}
							document.getElementById(event).innerHTML = log_2[0] + '\t\t\t'+ log_2[2];
						}
						else
						{
							event = "event" + i;
							document.getElementById(event).style.color="#666";
							document.getElementById(event).innerHTML = "";
						}
					}
				})
			}
			//清空告警日志内容
			function clearLog(pgn, pgs)
			{
				log_xhr.post('<%=controller%>admin/ACU_Antenna/clearAntLog', {token:'<%=token%>'}, function(x){
							
					var event = "";
					for(var i = 0; i < page_size ; i++)
					{
						event = "event" + i;
						document.getElementById(event).style.color="#666";
						document.getElementById(event).innerHTML = "";
					}
				})
			}
			//下一页
			function pageInc()
			{
				if(page_num >= MAX_PAGE)
				{
					page_num = MAX_PAGE;
				}
				else
				{
					page_num = page_num + 1;
				}
				getLog(page_num, page_size);
				document.getElementById("page").innerHTML = "<%:Page %>" + page_num;
			}
			//上一页
			function pageDesc()
			{
				if(page_num <= 0)
				{
					page_num = 0;
				}
				else
				{
					page_num = page_num - 1;
				}
				getLog(page_num, page_size);
				document.getElementById("page").innerHTML = "<%:Page %>" +  page_num;
			}
			getLog(page_num, page_size);
			setInterval(function () {
				getLog(page_num, page_size);
			}, 5000);

		</script>

	</body>
	</html>
<%+footer%>